package com.lc.advertising.ui.activity;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.load.MultiTransformation;
import com.bumptech.glide.load.resource.bitmap.CenterCrop;
import com.bumptech.glide.load.resource.bitmap.CircleCrop;
import com.hjq.http.EasyHttp;
import com.hjq.http.listener.HttpCallback;
import com.lc.advertising.R;
import com.lc.advertising.app.AppActivity;
import com.lc.advertising.http.glide.GlideApp;
import com.lc.advertising.http.request.QiangShowApi;
import com.lc.advertising.http.response.QiangShowBean;
import com.lc.advertising.other.IntentKey;
import com.lc.advertising.util.SPUtil;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class OrderListDetailsActivity extends AppActivity {
    @BindView(R.id.time)
    TextView time;
    @BindView(R.id.tv_staute)
    TextView tvStaute;
    @BindView(R.id.tv_start)
    TextView tvStart;
    @BindView(R.id.tv_end)
    TextView tvEnd;
    @BindView(R.id.tv_price)
    TextView tvPrice;
    @BindView(R.id.img_head)
    ImageView imgHead;
    @BindView(R.id.tv_name)
    TextView tvName;
    @BindView(R.id.tv_phone)
    TextView tvPhone;
    private String phone;
    @Override
    protected int getLayoutId() {
        return R.layout.activity_orderlistdetails;
    }

    @Override
    protected void initView() {

    }

    @Override
    protected void initData() {

    }

    private void qiang_show() {
        EasyHttp.post(this)
                .api(new QiangShowApi()
                        .setUid(SPUtil.get(this, IntentKey.UID, "")).setJingdu("").setWeidu("").setId( getIntent().getStringExtra("id")))
                .request(new HttpCallback<QiangShowBean>(this) {

                    @Override
                    public void onSucceed(QiangShowBean data) {
//
                        if (data.getCode() == 200) {
                            time.setText(data.getQiangdan().getCreate_time());
                            tvStart.setText(data.getQiangdan().getBegin_place());
                            tvEnd.setText(data.getQiangdan().getEnd_place());
                            tvStaute.setText(data.getQiangdan().getZhuangtai());

                            tvName.setText(data.getQiangdan().getMember_nickname());
                            GlideApp.with(getActivity())
                                    .load(IntentKey.URL + data.getQiangdan().getMember_headimg())
                                    .placeholder(R.mipmap.img_head)
                                    .error(R.mipmap.img_head)
                                    .transform(new MultiTransformation<>(new CenterCrop(), new CircleCrop()))
                                    .into(imgHead);

                            tvPrice.setText(data.getQiangdan().getPrice());

                            phone = data.getQiangdan().getMember_mobile();
                            tvPhone.setText(phone);


                        }

                    }


                });
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        ButterKnife.bind(this);
        qiang_show();

    }

    @OnClick(R.id.tv_tophone)
    public void onClick() {
        Intent dialIntent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + phone));//跳转到拨号界面，同时传递电话号码
        startActivity(dialIntent);
    }
}
